// pages/searchSchool/index.js
import {
  API,
  getUrl
} from '../../utils/api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight:wx.getSystemInfoSync()['statusBarHeight'],
    searchName:'',
    schoolList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getSchoolList();
  },
  getSchoolList(){
    wx.request({
      url: getUrl(API.SCHOOL_LIST),
      data: {
        schoolName: this.data.searchName
      },
      success: (res) => {
        this.setData({
          schoolList:res.data.data||[]
        })
      }
    })
  },
  searchNameInput: function (e) {
    this.setData({
      searchName: e.detail.value
    });
  },
  handelItemClick(event){
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.emit('searchSchoolEvent', {data:event.currentTarget.dataset.key});
    wx.navigateBack();
  }
})